package com.cjj.design_model;

class Singleton_2{

    private static final Singleton_2 singleton = new Singleton_2();

    static public Singleton_2 getSingleton(){
        return singleton;
    }

}

/**
 * @ClassName SingletonTest_2
 * @Date 2021/07/28 16:47:33
 * @Created by ccc-j
 * @email ccc-ju@outlook.com
 * 单例设计模式：饿汉式，线程安全
 */
public class SingletonTest_2 {

    public static void main(String[] args) {
        Singleton_2 singleton1 = Singleton_2.getSingleton();
        Singleton_2 singleton2 = Singleton_2.getSingleton();
        System.out.println(singleton1 == singleton2);
    }

}
